import { createRouter, createWebHistory } from 'vue-router'
import index from '../views/indexPage.vue'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'index',
      component: index
    },
    {
      path: '/main',
      name: 'main',
      component: () => import('../views/mainPage.vue'),
      redirect: '/main/mainPage',
      children:[
        {
          //有轮播图的那个界面
          path: 'mainPage',
          name: 'mainPage',
          component: () => import('../views/main/MainView.vue')
        },
        {
          path: 'category/:name',
          name: 'category',
          component: () => import('../views/main/CategoryView.vue')
        },
        // {
        //   path: 'categoryChess',
        //   name: 'categoryChess',
        //   component: () => import('../views/main/CategoryChessView.vue')
        // },
        {
          path: 'cart',
         //path: 'cart/:name',
          name: 'cart',
          component: () => import('../views/main/CartView.vue')
        },
        {
          path: 'order',
          name: 'order',
          component: () => import('../views/main/OrderView.vue')
        },
        {
          path: 'OrderDetail',
          name: 'OrderDetail',
          component: () => import('../views/main/OrderDetailView.vue')
        },
        {
          path: 'NewOrder',
          name: 'NewOrder',
          component: () => import('../views/main/NewOrderView.vue')
        },
        {
          path: 'ConfirmOrder',
          name: 'ConfirmOrder',
          component: () => import('../views/main/ConfirmOrderView.vue')
        },
        {
          path: 'account',
          name: 'account',
          component: () => import('../views/main/AccountView.vue')
        },
        {
          path: 'signOn',
          name: 'signOn',
          component: () => import('../views/main/SignOnView.vue')
        },
        {
          path: 'register',
          name: 'register',
          component: () => import('../views/main/RegisterView.vue')
        },
        {
          path: 'product/:name',
          // path: 'product',
          name: 'product',
          component: () => import('../views/main/ProductView.vue')
        },
        {
          //path: 'item',
          path: 'item/:id',
          name: 'item',
          component: () => import('../views/main/ItemView.vue')
        },
        {
          path: 'searchProduct/:productName',
          name: 'searchProduct',
          props: true,
          component: () => import('../views/main/SearchProduct.vue')
        },
      ]
    },
      //测试用alipay
    {
      path: '/alipay',
      name: 'alipay',
      component: () => import('../views/alipayTest.vue'),
    },
    {
      path:'/alipaySuccess',
      name:'alipaySuccess',
      component: () => import('../views/alipayTestSuccess.vue'),
    },

  ]
})

export default router
